package containsPattern;

public class Solution {
    public boolean containsPattern(int[] arr, int m, int k) {
        for (int i = 0; i < arr.length; i++) {
            if(check(i,i+m-1,arr,m,k)){
                return true;
            }
        }
        return false;
    }
    private boolean check(int l,int r,int[]arr,int m,int k){
        int count = 1;
        for (int i = r+1; i+m <arr.length ;) {
            for (int j = 0; j < m; j++) {
                if(arr[l+j]!=arr[i+j]){
                    return count>=k;
                }
            }
            count++;
            if(count>=k){
                return true;
            }
            i+=m;
        }
        return false;
    }
}
